package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class RegDemo
{
    public static void main(String[] args)
    {
        // 注册
        Scanner scanner = new Scanner(System.in);
        System.out.println("name = ");
        String name = scanner.nextLine();
        System.out.println("password = ");
        String passWord = scanner.nextLine();
        System.out.println("nickName = ");
        String nickName = scanner.nextLine();
        String sql = "insert into userinfo1 (username,password,nickname) values (" + name + ","
                + passWord + "," + nickName + ")";
        try(Connection connection = DBUtil.getConnection())
        {
            Statement statement = connection.createStatement();
            int i = statement.executeUpdate(sql);
            if (i > 0)
            {
                System.out.println("success");
            }
            else
            {
                System.out.println("failed");
            }
        }catch (SQLException e)
        {
            e.printStackTrace();
        }
    }

}
